﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Text;
namespace ltModel
{
    /// <summary>
    ///@tblName varchar(255), -- 表名
    ///@strGetFields varchar(1000) = '*', -- 需要返回的列 
    ///@fldName varchar(255)='', -- 排序的字段名 
    ///@PageSize int = 10, -- 页尺寸 
    ///@PageIndex int = 1, -- 页码 
    ///@OrderType bit = 0, -- 设置排序类型, 非 0 值则降序 
    ///@strWhere varchar(1500) = '' ,-- 查询条件 (注意: 不要加 where) 
    ///@Counts  int  out -- 返回记录总数, 非 0 值则返回 这里作运行后返回的记录总数分页用
    /// </summary>
    /// ----------------------------------------------------------------------------------
    ///@PageSize int=10 ,--每页显示的记录数
    ///@PageCurrent int=1 ,--当前要显示的页号
    ///@FdName varchar(100)='' ,--主键名或者标识列名
    ///@SelectStr varchar(2000)='', --select子句，不包含select关键字,如：*或者Id,UserId,UserName等。
    ///@FromStr varchar(1000)='', --from子句，不包含from关键子，如：myTable或者myTable,yourTable
    ///@WhereStr varchar(2000)='', --Where子句，不包含where关键字，如空的，或者 id>2 等
    ///@OrderByStr varchar(1000)='',--order by 子句，不包含order by 子句 ，如id desc,UserId asc 等
    ///@CountRows int=0 output, --返回记录总数
    ///@CountPage int=0 output --返回总页数

    public class PageFen
    {
        #region 初始值
        private int pagesize = 10;//每页显示的记录数
        private int pageindex = 1;//当前要显示的页号
        private string pkname = "ID";//主键名
        private string table;//不包含from关键子，如：myTable或者myTable,yourTable
        private string fields = "*";//不包含select关键字,如：*或者Id,UserId,UserName等
        private string orderby = "ID ASC";//order by 子句，不包含order by 子句 ，如id desc,UserId asc 等
        private string where = "";//Where子句，不包含where关键字，如空的，或者 id>2 等
        private string url = "";//地址栏参数获取

        private int ordertype = 1;
        private int rcount = 0;
        private string link;
        #endregion

        #region 初始值及属性

        public string PkName
        {
            get { return this.pkname; }
            set { this.pkname = value; }
        }
        /// <summary>
        /// 表名
        /// </summary>
        public string Table
        {
            get { return this.table; }
            set { this.table = value; }
        }
        /// <summary>
        /// 需要返回的列 
        /// </summary>
        public string Fields
        {
            get { return this.fields; }
            set { this.fields = value; }
        }
        /// <summary>
        ///  排序的字段名 
        /// </summary>
        public string OrderBy
        {
            get { return this.orderby; }
            set { this.orderby = value; }
        }
        /// <summary>
        /// 条件
        /// </summary>
        public string Where
        {
            get { return this.where; }
            set { this.where = value; }
        }
        /// <summary>
        /// 每页显示的条数
        /// </summary>
        public int PageSize
        {
            get { return this.pagesize; }
            set
            {
                if (this.pagesize > 1)
                    this.pagesize = value;
                else
                    this.pagesize = 10;
            }
        }
        /// <summary>
        /// 当前页
        /// </summary>
        public int PageIndex
        {
            get { return this.pageindex; }
            set
            {
                if (this.pageindex >= 1)
                    this.pageindex = value;
                else
                    this.pageindex = 1;
            }
        }
        /// <summary>
        /// 0为顺序，1为倒序
        /// </summary>
        public int OrderType
        {
            get { return this.ordertype; }
            set { this.ordertype = value; }
        }
        public string Link
        {
            get { return this.link; }
        }
        /// <summary>
        /// 地址栏参数
        /// </summary>
        public string Url
        {
            get { return url; }
            set { url = value; }
        }
        public int Rcount
        {
            get { return rcount; }
            set { rcount = value; }
        }
        #endregion

        public PageFen()
        {
            if (ordertype == 1)
                this.orderby = "ID Desc";
        }

        public PageFen(string table, string fields, string orderby, string pkname, int pagesize, int pageindex, int ordertype, string where)
        {
            this.table = table;
            this.fields = fields;
            //this.orderby = orderby;
            this.pkname = pkname;
            this.pagesize = pagesize;
            this.pageindex = pageindex;
            this.ordertype = ordertype;
            this.where = where;

            if (ordertype == 1)
                this.orderby = "ID Desc";
        }

        /// <summary>
        /// 返回分页后的记录
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public DataTable GetList()
        {
            if (url == "")
                url = "?";
            else
                url = "?" + url + "&";

            if (HttpContext.Current.Request.QueryString["pageindex"] != null)
            {
                string cix = HttpContext.Current.Request.QueryString["pageindex"].ToString();
                if (PageValidate.IsNumber(cix) == false)
                    this.pageindex = 1;
                else
                    this.pageindex = Int32.Parse(cix);
            }
            int sumcount;//总记录数
            int sumpage;//总页数
            string procName = "PageShowOne";//存储过程名

            /*
            SqlParameter[] para=new SqlParameter[]{
                                                      new SqlParameter("@tblName",this.table),
                                                      new SqlParameter("@strGetFields",this.fields),
                                                      new SqlParameter("@fldName",this.orderby), 
                                                      new SqlParameter("@PageSize",this.pagesize),
                                                      new SqlParameter("@PageIndex",this.pageindex), 
                                                      new SqlParameter("@OrderType",this.ordertype),
                                                      new SqlParameter("@strWhere",this.where),
                                                      new SqlParameter("@Counts",SqlDbType.Int)
														 										  
                                                  };
    ///@PageSize int=10 ,--每页显示的记录数
    ///@PageCurrent int=1 ,--当前要显示的页号
    ///@FdName varchar(100)='' ,--主键名或者标识列名
    ///@SelectStr varchar(2000)='', --select子句，不包含select关键字,如：*或者Id,UserId,UserName等。
    ///@FromStr varchar(1000)='', --from子句，不包含from关键子，如：myTable或者myTable,yourTable
    ///@WhereStr varchar(2000)='', --Where子句，不包含where关键字，如空的，或者 id>2 等
    ///@OrderByStr varchar(1000)='',--order by 子句，不包含order by 子句 ，如id desc,UserId asc 等
    ///@CountRows int=0 output, --返回记录总数
    ///@CountPage int=0 output --返回总页数
            */
            SqlParameter[] para = new SqlParameter[]{
													  new SqlParameter("@PageSize",this.pagesize),
													  new SqlParameter("@PageCurrent",this.pageindex), 
													  new SqlParameter("@FdName",this.pkname),
													  new SqlParameter("@SelectStr",this.fields),
													  new SqlParameter("@FromStr",this.table),
													  new SqlParameter("@WhereStr",this.where),
													  new SqlParameter("@OrderByStr",this.orderby), 
													  new SqlParameter("@CountRows",SqlDbType.Int),
													  new SqlParameter("@CountPage",SqlDbType.Int)
														 										  
												  };

            para[7].Direction = ParameterDirection.Output;


            DataTable dt = new DataTable();
            dt = DataObject.RunProcedure(procName, para, table).Tables[0];

            sumcount = Convert.ToInt32(para[7].Value);//取得总记录数
            rcount = sumcount;
            sumpage = (int)Math.Ceiling((double)sumcount / pagesize);//计算分成多少页

            int iStart = pageindex - 3;
            int iEnd = pageindex + 2;

            if (iStart < 0) iStart = 0;
            if (iEnd > sumpage) iEnd = sumpage;


            if (sumpage >= 1)
            {

                link += "第" + pageindex.ToString() + "页/共" + sumpage.ToString() + "页&nbsp;每页" + this.pagesize + "条/共" + sumcount.ToString() + "条记录";

                if (this.pageindex != 1)
                {
                    link += "&nbsp<a href='" + url + "pageindex=1'>首页</a>";
                    link += "&nbsp<a href='" + url + "pageindex=" + (this.pageindex - 1) + "'>上一页</a>";

                }
                else
                {
                    link += "&nbsp首页";
                    link += "&nbsp上一页";
                }
                if (this.pageindex != sumpage)
                {
                    link += "&nbsp<a href='" + url + "pageindex=" + (this.pageindex + 1) + "'>下一页</a>";
                    link += "&nbsp<a href='" + url + "pageindex=" + sumpage + "'>末页</a>";
                }
                else
                {
                    link += "&nbsp下一页";
                    link += "&nbsp末页";
                }
                link += "&nbsp;转到:<select name='fey' onchange=\"location.href='" + url + "pageindex='+this.value\">";
                for (int i = 1; i <= sumpage; i++)
                {
                    if (i == this.pageindex)
                        link += "<option value=" + i + " selected='selected'>" + i + "</option>";
                    else
                        link += "<option value=" + i + " >" + i + "</option>";
                }
                link += "</select>";
                link += "页&nbsp;";
                link = "<div align='right' style=\"margin-right:20px;\">" + link + "</div>";
            }
            return dt;
        }

        public DataTable GetList1()
        {
            if (url == "")
                url = "?";
            else
                url = "?" + url + "&";

            if (HttpContext.Current.Request.QueryString["pageindex"] != null)
            {
                string cix = HttpContext.Current.Request.QueryString["pageindex"].ToString();
                if (PageValidate.IsNumber(cix) == false)
                    this.pageindex = 1;
                else
                    this.pageindex = Int32.Parse(cix);
            }
            int sumcount;//总记录数
            int sumpage;//总页数
            string procName = "PageShowOne";//存储过程名

            /*
            SqlParameter[] para=new SqlParameter[]{
                                                      new SqlParameter("@tblName",this.table),
                                                      new SqlParameter("@strGetFields",this.fields),
                                                      new SqlParameter("@fldName",this.orderby), 
                                                      new SqlParameter("@PageSize",this.pagesize),
                                                      new SqlParameter("@PageIndex",this.pageindex), 
                                                      new SqlParameter("@OrderType",this.ordertype),
                                                      new SqlParameter("@strWhere",this.where),
                                                      new SqlParameter("@Counts",SqlDbType.Int)
														 										  
                                                  };
    ///@PageSize int=10 ,--每页显示的记录数
    ///@PageCurrent int=1 ,--当前要显示的页号
    ///@FdName varchar(100)='' ,--主键名或者标识列名
    ///@SelectStr varchar(2000)='', --select子句，不包含select关键字,如：*或者Id,UserId,UserName等。
    ///@FromStr varchar(1000)='', --from子句，不包含from关键子，如：myTable或者myTable,yourTable
    ///@WhereStr varchar(2000)='', --Where子句，不包含where关键字，如空的，或者 id>2 等
    ///@OrderByStr varchar(1000)='',--order by 子句，不包含order by 子句 ，如id desc,UserId asc 等
    ///@CountRows int=0 output, --返回记录总数
    ///@CountPage int=0 output --返回总页数
            */
            SqlParameter[] para = new SqlParameter[]{
                                                      new SqlParameter("@PageSize",this.pagesize),
                                                      new SqlParameter("@PageCurrent",this.pageindex), 
                                                      new SqlParameter("@FdName",this.pkname),
                                                      new SqlParameter("@SelectStr",this.fields),
                                                      new SqlParameter("@FromStr",this.table),
                                                      new SqlParameter("@WhereStr",this.where),
                                                      new SqlParameter("@OrderByStr",this.orderby), 
                                                      new SqlParameter("@CountRows",SqlDbType.Int),
                                                      new SqlParameter("@CountPage",SqlDbType.Int)
														 										  
                                                  };

            para[7].Direction = ParameterDirection.Output;


            DataTable dt = new DataTable();
            dt = DataObject.RunProcedure(procName, para, table).Tables[0];

            sumcount = Convert.ToInt32(para[7].Value);//取得总记录数
            rcount = sumcount;
            sumpage = (int)Math.Ceiling((double)sumcount / pagesize);//计算分成多少页

            int iStart = pageindex - 3;
            int iEnd = pageindex + 2;

            if (iStart < 0) iStart = 0;
            if (iEnd > sumpage) iEnd = sumpage;

            string strlink = "";
            string strlink1 = "";
            string strres = "";
            if (sumpage >= 1)
            {

                //link += "第" + pageindex.ToString() + "页/共" + sumpage.ToString() + "页&nbsp;每页" + this.pagesize + "条/共" + sumcount.ToString() + "条记录";

                if (this.pageindex != 1)
                {
                    strlink += "&nbsp<a href='" + url + "pageindex=1'><u><img src=\"images/First.gif\" width=\"9\" height=\"8\" border=\"0\"></u></a>";
                    strlink += "&nbsp<a href='" + url + "pageindex=" + (this.pageindex - 1) + "'><u><img src=\"images/Previous.gif\" width=\"8\" height=\"8\" border=\"0\"></u></a>";

                }
                else
                {
                    strlink += "&nbsp<u><img src=\"images/First.gif\" width=\"9\" height=\"8\" border=\"0\"></u>";
                    strlink += "&nbsp<u><img src=\"images/Previous.gif\" width=\"8\" height=\"8\" border=\"0\"></u>";
                }

                strlink += "&nbsp;第 <font color=\"#FF0000\">" + pageindex.ToString() + "</font>页";

                if (this.pageindex != sumpage)
                {
                    strlink += "&nbsp<a href='" + url + "pageindex=" + (this.pageindex + 1) + "'><u><img src=\"images/Next.gif\" width=\"8\" height=\"8\" border=\"0\"></u></a>";
                    strlink += "&nbsp<a href='" + url + "pageindex=" + sumpage + "'><u><img src=\"images/Last.gif\" width=\"9\" height=\"8\" border=\"0\"></u></a>";
                }
                else
                {
                    strlink += "&nbsp<u><img src=\"images/Next.gif\" width=\"8\" height=\"8\" border=\"0\"></u>";
                    strlink += "&nbsp<u><img src=\"images/Last.gif\" width=\"9\" height=\"8\" border=\"0\"></u>";
                }

                strlink += "&nbsp;共 <font color=\"#FF0000\">" + sumpage.ToString() + "</font> 页 每页<font color=\"#FF0000\">" + this.pagesize + "</font>条信息/共<font color=\"#FF0000\">" + sumcount.ToString() + "</font>条信息";

                strlink1 += "<select name='fey' onchange=\"location.href='" + url + "pageindex='+this.value\">";
                for (int i = 1; i <= sumpage; i++)
                {
                    if (i == this.pageindex)
                        strlink1 += "<option value=" + i + " selected='selected'>第" + i + "页</option>";
                    else
                        strlink1 += "<option value=" + i + " >第" + i + "页</option>";
                }
                strlink1 += "</select>";
                //link += "页&nbsp;";
                //link = "<div align='right' style=\"margin-right:20px;\">" + link + "</div>";

                strres = strres + "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"40\">";
                strres = strres + "<tr>\r\n";
                strres = strres + "<td style=\"width: 580px\">" + strlink + "</td>\r\n";
                strres = strres + "<td align=\"right\">&nbsp;&nbsp;" + strlink1 + "</td>\r\n";
                strres = strres + "</tr>\r\n";
                strres = strres + "</table>\r\n";

                link = strres;

            }
            return dt;
        }

        public DataTable GetList2()
        {
            if (url == "")
                url = "?";
            else
                url = "?" + url + "&";

            if (HttpContext.Current.Request.QueryString["pageindex"] != null)
            {
                string cix = HttpContext.Current.Request.QueryString["pageindex"].ToString();
                if (PageValidate.IsNumber(cix) == false)
                    this.pageindex = 1;
                else
                    this.pageindex = Int32.Parse(cix);
            }
            int sumcount;//总记录数
            int sumpage;//总页数
            string procName = "PageShowOne";//存储过程名

            /*
            SqlParameter[] para=new SqlParameter[]{
                                                      new SqlParameter("@tblName",this.table),
                                                      new SqlParameter("@strGetFields",this.fields),
                                                      new SqlParameter("@fldName",this.orderby), 
                                                      new SqlParameter("@PageSize",this.pagesize),
                                                      new SqlParameter("@PageIndex",this.pageindex), 
                                                      new SqlParameter("@OrderType",this.ordertype),
                                                      new SqlParameter("@strWhere",this.where),
                                                      new SqlParameter("@Counts",SqlDbType.Int)
														 										  
                                                  };
    ///@PageSize int=10 ,--每页显示的记录数
    ///@PageCurrent int=1 ,--当前要显示的页号
    ///@FdName varchar(100)='' ,--主键名或者标识列名
    ///@SelectStr varchar(2000)='', --select子句，不包含select关键字,如：*或者Id,UserId,UserName等。
    ///@FromStr varchar(1000)='', --from子句，不包含from关键子，如：myTable或者myTable,yourTable
    ///@WhereStr varchar(2000)='', --Where子句，不包含where关键字，如空的，或者 id>2 等
    ///@OrderByStr varchar(1000)='',--order by 子句，不包含order by 子句 ，如id desc,UserId asc 等
    ///@CountRows int=0 output, --返回记录总数
    ///@CountPage int=0 output --返回总页数
            */
            SqlParameter[] para = new SqlParameter[]{
													  new SqlParameter("@PageSize",this.pagesize),
													  new SqlParameter("@PageCurrent",this.pageindex), 
													  new SqlParameter("@FdName",this.pkname),
													  new SqlParameter("@SelectStr",this.fields),
													  new SqlParameter("@FromStr",this.table),
													  new SqlParameter("@WhereStr",this.where),
													  new SqlParameter("@OrderByStr",this.orderby), 
													  new SqlParameter("@CountRows",SqlDbType.Int),
													  new SqlParameter("@CountPage",SqlDbType.Int)
														 										  
												  };

            para[7].Direction = ParameterDirection.Output;


            DataTable dt = new DataTable();
            dt = DataObject.RunProcedure(procName, para, table).Tables[0];

            sumcount = Convert.ToInt32(para[7].Value);//取得总记录数
            rcount = sumcount;
            sumpage = (int)Math.Ceiling((double)sumcount / pagesize);//计算分成多少页

            int iStart = pageindex - 3;
            int iEnd = pageindex + 2;

            if (iStart < 0) iStart = 0;
            if (iEnd > sumpage) iEnd = sumpage;

            string strlink = "";
            string strlink1 = "";
            string strres = "";
            if (sumpage >= 1)
            {

                //link += "第" + pageindex.ToString() + "页/共" + sumpage.ToString() + "页&nbsp;每页" + this.pagesize + "条/共" + sumcount.ToString() + "条记录";

                if (this.pageindex != 1)
                {
                    strlink += "&nbsp<a href='" + url + "pageindex=1'><u><img src=\"images/First.gif\" width=\"9\" height=\"8\" border=\"0\"></u></a>";
                    strlink += "&nbsp<a href='" + url + "pageindex=" + (this.pageindex - 1) + "'><u><img src=\"images/Previous.gif\" width=\"8\" height=\"8\" border=\"0\"></u></a>";

                }
                else
                {
                    strlink += "&nbsp<u><img src=\"images/First.gif\" width=\"9\" height=\"8\" border=\"0\"></u>";
                    strlink += "&nbsp<u><img src=\"images/Previous.gif\" width=\"8\" height=\"8\" border=\"0\"></u>";
                }

                strlink += "&nbsp;第 <font color=\"#FF0000\">" + pageindex.ToString() + "</font>页";

                if (this.pageindex != sumpage)
                {
                    strlink += "&nbsp<a href='" + url + "pageindex=" + (this.pageindex + 1) + "'><u><img src=\"images/Next.gif\" width=\"8\" height=\"8\" border=\"0\"></u></a>";
                    strlink += "&nbsp<a href='" + url + "pageindex=" + sumpage + "'><u><img src=\"images/Last.gif\" width=\"9\" height=\"8\" border=\"0\"></u></a>";
                }
                else
                {
                    strlink += "&nbsp<u><img src=\"images/Next.gif\" width=\"8\" height=\"8\" border=\"0\"></u>";
                    strlink += "&nbsp<u><img src=\"images/Last.gif\" width=\"9\" height=\"8\" border=\"0\"></u>";
                }

                strlink += "&nbsp;共 <font color=\"#FF0000\">" + sumpage.ToString() + "</font> 页 每页<font color=\"#FF0000\">" + this.pagesize + "</font>张图片/共<font color=\"#FF0000\">" + sumcount.ToString() + "</font>张图片";

                strlink1 += "<select name='fey' onchange=\"location.href='" + url + "pageindex='+this.value\">";
                for (int i = 1; i <= sumpage; i++)
                {
                    if (i == this.pageindex)
                        strlink1 += "<option value=" + i + " selected='selected'>第" + i + "页</option>";
                    else
                        strlink1 += "<option value=" + i + " >第" + i + "页</option>";
                }
                strlink1 += "</select>";
                //link += "页&nbsp;";
                //link = "<div align='right' style=\"margin-right:20px;\">" + link + "</div>";

                strres = strres + "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"40\">";
                strres = strres + "<tr>\r\n";
                strres = strres + "<td style=\"width: 580px\">" + strlink + "</td>\r\n";
                strres = strres + "<td align=\"right\">&nbsp;&nbsp;" + strlink1 + "</td>\r\n";
                strres = strres + "</tr>\r\n";
                strres = strres + "</table>\r\n";

                link = strres;

            }
            return dt;
        }

        public DataTable GetListForProject(int projectTypeID, int projectStreetID)
        {
            StringBuilder buildUrl = new StringBuilder();
            string urlParameter = "?projectType={0}&projectStreet={1}&";
            buildUrl.Append(HttpContext.Current.Request.Url.AbsolutePath + string.Format(urlParameter,projectTypeID,projectStreetID));
            url = buildUrl.ToString();

            if (HttpContext.Current.Request.QueryString["pageindex"] != null)
            {
                string cix = HttpContext.Current.Request.QueryString["pageindex"].ToString();
                if (PageValidate.IsNumber(cix) == false)
                    this.pageindex = 1;
                else
                    this.pageindex = Int32.Parse(cix);
            }
            int sumcount;//总记录数
            int sumpage;//总页数
            string procName = "PageShowOne";//存储过程名

            /*
            SqlParameter[] para=new SqlParameter[]{
                                                      new SqlParameter("@tblName",this.table),
                                                      new SqlParameter("@strGetFields",this.fields),
                                                      new SqlParameter("@fldName",this.orderby), 
                                                      new SqlParameter("@PageSize",this.pagesize),
                                                      new SqlParameter("@PageIndex",this.pageindex), 
                                                      new SqlParameter("@OrderType",this.ordertype),
                                                      new SqlParameter("@strWhere",this.where),
                                                      new SqlParameter("@Counts",SqlDbType.Int)
														 										  
                                                  };
    ///@PageSize int=10 ,--每页显示的记录数
    ///@PageCurrent int=1 ,--当前要显示的页号
    ///@FdName varchar(100)='' ,--主键名或者标识列名
    ///@SelectStr varchar(2000)='', --select子句，不包含select关键字,如：*或者Id,UserId,UserName等。
    ///@FromStr varchar(1000)='', --from子句，不包含from关键子，如：myTable或者myTable,yourTable
    ///@WhereStr varchar(2000)='', --Where子句，不包含where关键字，如空的，或者 id>2 等
    ///@OrderByStr varchar(1000)='',--order by 子句，不包含order by 子句 ，如id desc,UserId asc 等
    ///@CountRows int=0 output, --返回记录总数
    ///@CountPage int=0 output --返回总页数
            */
            SqlParameter[] para = new SqlParameter[]{
													  new SqlParameter("@PageSize",this.pagesize),
													  new SqlParameter("@PageCurrent",this.pageindex), 
													  new SqlParameter("@FdName",this.pkname),
													  new SqlParameter("@SelectStr",this.fields),
													  new SqlParameter("@FromStr",this.table),
													  new SqlParameter("@WhereStr",this.where),
													  new SqlParameter("@OrderByStr",this.orderby), 
													  new SqlParameter("@CountRows",SqlDbType.Int),
													  new SqlParameter("@CountPage",SqlDbType.Int)
														 										  
												  };

            para[7].Direction = ParameterDirection.Output;


            DataTable dt = new DataTable();
            dt = DataObject.RunProcedure(procName, para, table).Tables[0];

            sumcount = Convert.ToInt32(para[7].Value);//取得总记录数
            rcount = sumcount;
            sumpage = (int)Math.Ceiling((double)sumcount / pagesize);//计算分成多少页

            int iStart = pageindex - 3;
            int iEnd = pageindex + 2;

            if (iStart < 0) iStart = 0;
            if (iEnd > sumpage) iEnd = sumpage;

            string strlink = "";
            string strlink1 = "";
            string strres = "";
            if (sumpage >= 1)
            {

                //link += "第" + pageindex.ToString() + "页/共" + sumpage.ToString() + "页&nbsp;每页" + this.pagesize + "条/共" + sumcount.ToString() + "条记录";

                if (this.pageindex != 1)
                {
                    strlink += "&nbsp<a href='" + url + "pageindex=1'><u><img src=\"images/First.gif\" width=\"9\" height=\"8\" border=\"0\"></u></a>";
                    strlink += "&nbsp<a href='" + url + "pageindex=" + (this.pageindex - 1) + "'><u><img src=\"images/Previous.gif\" width=\"8\" height=\"8\" border=\"0\"></u></a>";

                }
                else
                {
                    strlink += "&nbsp<u><img src=\"images/First.gif\" width=\"9\" height=\"8\" border=\"0\"></u>";
                    strlink += "&nbsp<u><img src=\"images/Previous.gif\" width=\"8\" height=\"8\" border=\"0\"></u>";
                }

                strlink += "&nbsp;第 <font color=\"#FF0000\">" + pageindex.ToString() + "</font>页";

                if (this.pageindex != sumpage)
                {
                    strlink += "&nbsp<a href='" + url + "pageindex=" + (this.pageindex + 1) + "'><u><img src=\"images/Next.gif\" width=\"8\" height=\"8\" border=\"0\"></u></a>";
                    strlink += "&nbsp<a href='" + url + "pageindex=" + sumpage + "'><u><img src=\"images/Last.gif\" width=\"9\" height=\"8\" border=\"0\"></u></a>";
                }
                else
                {
                    strlink += "&nbsp<u><img src=\"images/Next.gif\" width=\"8\" height=\"8\" border=\"0\"></u>";
                    strlink += "&nbsp<u><img src=\"images/Last.gif\" width=\"9\" height=\"8\" border=\"0\"></u>";
                }

                strlink += "&nbsp;共 <font color=\"#FF0000\">" + sumpage.ToString() + "</font> 页 每页<font color=\"#FF0000\">" + this.pagesize + "</font>条信息/共<font color=\"#FF0000\">" + sumcount.ToString() + "</font>条信息";

                strlink1 += "<select name='fey' onchange=\"location.href='" + url + "pageindex='+this.value\">";
                for (int i = 1; i <= sumpage; i++)
                {
                    if (i == this.pageindex)
                        strlink1 += "<option value=" + i + " selected='selected'>第" + i + "页</option>";
                    else
                        strlink1 += "<option value=" + i + " >第" + i + "页</option>";
                }
                strlink1 += "</select>";
                //link += "页&nbsp;";
                //link = "<div align='right' style=\"margin-right:20px;\">" + link + "</div>";

                strres = strres + "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" height=\"40\">";
                strres = strres + "<tr>\r\n";
                strres = strres + "<td style=\"width: 580px\">" + strlink + "</td>\r\n";
                strres = strres + "<td align=\"right\">&nbsp;&nbsp;" + strlink1 + "</td>\r\n";
                strres = strres + "</tr>\r\n";
                strres = strres + "</table>\r\n";

                link = strres;

            }
            return dt;
        }
    }
}
